package com.truthbean.jeetb.utils.web;

import java.io.File;
import java.util.Comparator;

public class FileComparator implements Comparator<File> {
    public int compare(File f1, File f2) {
        if (f1 != null && f2 != null) {
            if (f1.isDirectory()) {
                if (f2.isDirectory()) {
                    return f1.getName().compareTo(f2.getName());
                } else {
                    return -1;
                }
            } else {
                if (f2.isDirectory()) {
                    return 1;
                } else {
                    return f1.getName().compareTo(f2.getName());
                }
            }
        }
        return 0;
    }
}